﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace idataplatform
{
    public partial class hymnlist : Form
    {
        public hymnlist()
        {
            InitializeComponent();
        }

        private void hymnlist_Load(object sender, EventArgs e)
        {
            conncls conns = new conncls();
            string hymnSQL = "SELECT t2.HYNO,t2.PHONENO,t2.HYTIME FROM(SELECT t1.HYNO, t1.PHONENO, t1.HYTIME, ROW_NUMBER() OVER(PARTITION BY t1.HYNO ORDER BY t1.HYTIME DESC) Num FROM (SELECT HYNO, PHONENO, JFTIME AS HYTIME FROM jfchange_ipark where jftime >= '"+ DateTime.Now.Date.AddDays(-8).ToShortDateString()+"' AND jftime <= '"+ DateTime.Now.Date.AddDays(-1).ToShortDateString() + "' AND jfmark <> '新用户奖励积分' AND jfmark <> '测试' AND HYNO <> '' UNION ALL SELECT HYNO, PHONENO, hxtime AS HYTIME FROM qhxtab_ipark where HXTIME >= '"+ DateTime.Now.Date.AddDays(-8).ToShortDateString() + "' and HXTIME <= '" + DateTime.Now.Date.AddDays(-1).ToShortDateString() + "' AND HYNO <> '') t1 ) t2 WHERE t2.Num = 1";
            
            dataGridView1.DataSource = conns.Dts(hymnSQL);
            toolStripStatusLabel1.Text = dataGridView1.Rows.Count.ToString() + " 行";
        }

        private void 条件查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            hyhydsel form2 = new hyhydsel();
            form2.ShowDialog();
            if (form2.DialogResult == DialogResult.OK)
            {
                if (pubcls.hylselSQL != "")
                {
                    conncls conns = new conncls();
                    dataGridView1.DataSource = conns.Dts(pubcls.hylselSQL);
                    toolStripStatusLabel1.Text = dataGridView1.Rows.Count.ToString() + " 行";
                }
            }
        }

        private void 数据导出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ExportExcel Et = new ExportExcel();
            Et.GridToExcel("招商蛇口佛山IPARK花园城活跃会员数据", dataGridView1);
        }
    }
}
